<html>
<?php 
// session_start();
echo('Hello sssss')
// function submitfunc() {
//     if(isset($_POST['nadawca']) and isset($_POST['odbiorca']) and isset($_POST['wiadomosc']) and isset($_POST['temat'])) {
//         $to      = $_POST['odbiorca'];
  
//     else{
//         echo "fail";
//     }
// }

?>
<?php

$doc = new DOMDocument;

$headNode = $doc->createElement("head");
$doc->appendChild($headNode);

function submitfunc() {
    if(isset($_POST['inp'])){
        $titleNode = $doc->createElement("title");
        $titleNode.$headNode->appendChild($titleNode);

        echo $doc->saveXML();}
  
    else{
        echo "fail";
    }
    
}

?>
<body>   
<form action="?action=submitfunc" method="POST">
<input type="text" name="inp" id='inp'>
<input type="submit">
<button onclick='addHistory()'>
useless
</button>
</form>
<div id='d'>
    
</div>

</body>

</html>
<script>
    var css = ' html, body { background: #222;}'
    head = document.head || document.getElementsByTagName('head')[0],
    style = document.createElement('style');

head.appendChild(style);

style.type = 'text/css';
style.appendChild(document.createTextNode(css));

j=0
function addHistory(){
 
    var element = document.createElement("p")

    element.innerText=document.getElementById('inp').value
   
    // document.getElementById('d').append(element)
    document.appendChild(element)
    // alert(document.getElementById('inp').value)

    j+=1
}
</script>
